# decoding=utf-8
import psycopg2
import hashlib
import os


def insert_admin():
    try:
        salt = os.urandom(24).encode('base-64')[:-1]
        password_db = hashlib.sha256('19961231'+salt).hexdigest()
        print salt
        print password_db

        conn = psycopg2.connect(database="reform", user="postgres", password="postgres", host="reform-postgres",
                                port="5432")
        cur = conn.cursor()
        cur.execute(u"insert into users(id,password,salt,user_group) values (%s,%s,%s,%s)",
                    (201594095, password_db, salt, 0))
        conn.commit()
    except Exception, e:
        print Exception, ":", e
    finally:
        cur.close()
        conn.close()
